package com.ace.lab.pays.service;

import com.ace.lab.pays.dto.AccountProto;
import com.ace.lab.pays.dto.BalanceQueryRequestProto;
import com.ace.lab.pays.dto.BalanceQueryResponseProto;
import com.google.protobuf.Empty;
import io.grpc.stub.StreamObserver;
import org.springframework.stereotype.Service;

@Service
public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBase {

    @Override
    public void queryAccountBalance(BalanceQueryRequestProto.BalanceQueryRequest request, StreamObserver<BalanceQueryResponseProto.BalanceQueryResponse> responseObserver) {
        long accountId = request.getAccountId();
        BalanceQueryResponseProto.BalanceQueryResponse response = BalanceQueryResponseProto.BalanceQueryResponse.newBuilder()
                .setBalance("100.00")
                .build();
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    }

    @Override
    public void createAccount(AccountProto.Account request, StreamObserver<Empty> responseObserver) {
        responseObserver.onNext(Empty.getDefaultInstance());
        responseObserver.onCompleted();
    }

}
